/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number[]}
 */
const twoSum = function (nums, target) {
  const myObject = {}
  for (let i = 0; i < nums.length; i++) {
    const complement = target - nums[i]
    if (myObject.hasOwnProperty(complement)) {
      return [myObject[complement], i]
    }
    myObject[nums[i]] = i
  }
}
